package com.haixiaoke.saas.repository.service.impl;

import cn.hutool.core.date.DateUtil;
import com.haixiaoke.saas.repository.mapper.RecommendItemMapper;
import com.haixiaoke.saas.repository.pojo.RecommendItem;
import com.haixiaoke.saas.repository.service.IRecommendItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 推荐房源Service业务层处理
 *
 * @author zhiping
 * @date 2023-04-18
 */
@Service
public class RecommendItemServiceImpl implements IRecommendItemService {
    @Autowired
    private RecommendItemMapper recommendItemMapper;

    /**
     * 查询推荐房源
     *
     * @param itemId 推荐房源主键
     * @return 推荐房源
     */
    @Override
    public RecommendItem selectRecommendItemByItemId(Long itemId) {
        return recommendItemMapper.selectRecommendItemByItemId(itemId);
    }

    /**
     * 查询推荐房源列表
     *
     * @param recommendItem 推荐房源
     * @return 推荐房源
     */
    @Override
    public List<RecommendItem> selectRecommendItemList(RecommendItem recommendItem) {
        return recommendItemMapper.selectRecommendItemList(recommendItem);
    }

    /**
     * 新增推荐房源
     *
     * @param recommendItem 推荐房源
     * @return 结果
     */
    @Override
    public int insertRecommendItem(RecommendItem recommendItem) {
        recommendItem.setCreateTime(DateUtil.date());
        return recommendItemMapper.insertRecommendItem(recommendItem);
    }

    /**
     * 修改推荐房源
     *
     * @param recommendItem 推荐房源
     * @return 结果
     */
    @Override
    public int updateRecommendItem(RecommendItem recommendItem) {
        recommendItem.setUpdateTime(DateUtil.date());
        return recommendItemMapper.updateRecommendItem(recommendItem);
    }

    /**
     * 批量删除推荐房源
     *
     * @param itemIds 需要删除的推荐房源主键
     * @return 结果
     */
    @Override
    public int deleteRecommendItemByItemIds(Long[] itemIds) {
        return recommendItemMapper.deleteRecommendItemByItemIds(itemIds);
    }

    /**
     * 删除推荐房源信息
     *
     * @param itemId 推荐房源主键
     * @return 结果
     */
    @Override
    public int deleteRecommendItemByItemId(Long itemId) {
        return recommendItemMapper.deleteRecommendItemByItemId(itemId);
    }

    @Override
    public int batchInsertRecommendItems(List<RecommendItem> items) {
        return recommendItemMapper.batchInsertRecommendItems(items);
    }
}
